<?php

class Admin_Form_LaboratorioMiembro extends Zend_Form {

    public function init() {
        $default_messages = Zend_Registry::get('default_messages');
        
        // Set the method for the display form to POST
        $this->setMethod('post');
        $this->setAttrib('id', 'form-lab-miebro');
        $this->setAttrib('class', 'form-horizontal mini-layout-body');

        $area_academica = new Application_Model_Mapper_AreaAcademica();
        $area_db = $area_academica->fetchAll();
        $area = new Zend_Form_Element_Select('codigo_area_academica');
        $area->addMultiOption(-1, $default_messages->input_select_select); // debe de ser un mensaje
        foreach ($area_db as $value) {
            $a = $value->toArray();
            $area->addMultiOption($a['codigo_area_academica'], $a['nombre']);
        }
        $area->setLabel('Área académica (* Campo ayuda)');
        $area->setAttrib('onblur', 'loadCursos()');
        $this->addElement($area);

        $curso = new Application_Model_Mapper_Curso();
        $curso_db = $curso->fetchAll();
        $codigo_curso = new Zend_Form_Element_Select('codigo_curso');
        $codigo_curso->addMultiOption(-1, $default_messages->input_select_select); // debe de ser un mensaje
        foreach ($curso_db as $value) {
            $c = $value->toArray();
            $codigo_curso->addMultiOption($c['codigo_curso'], $c['nombre']);
        }
        $codigo_curso->setLabel('Curso');
        $this->addElement($codigo_curso);

        $this->addElement('text', 'nombre', array(
            'label' => 'Nombre:',
            'required' => false,
            'class' => 'input-block-level',
            'validators' => array(
                array('validator' => 'StringLength', 'options' => array(0, 255))
            )
        ));

        $this->addElement('text', 'descripcion', array(
            'label' => 'Descripcion:',
            'required' => false,
            'class' => 'input-block-level',
            'validators' => array(
                array('validator' => 'StringLength', 'options' => array(0, 255))
            )
        ));

        $this->addElement('text', 'cantidad_maquinas', array(
            'label' => 'Cantidad maquinas:',
            'required' => true,
            'class' => 'input-block-level',
            'validators' => array(
                array('validator' => 'Digits', 'options' => array(1, 2))
            )
        ));

        
        $this->addElement('button', 'guardar', array(
            'ignore' => true,
            'label' => 'Guardar',
            'onclick' => 'saveLaboratorio()',
            'class' => 'btn btn-large btn-primary'
            
        ));
        
        $this->addElement('button', 'cancel', array(
            'ignore' => true,
            'label' => 'Cancelar',
            'onclick' => 'back()',
            'class' => 'btn btn-large btn-primary'
        ));
    }

}

?>
